<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.global.js"></script>
</head>
<body>
    <div id="app">
        <!--        子传父4:组件上定义方法-->
        <my-head @custom-click="handleClick"></my-head>
    </div>
    <script>
        let app = Vue.createApp({
            data(){
                return {
                    count: 10
                }
            },
            methods:{
                //子传父4:父组件接收子组件发送的数据
                handleClick(data) {
                    console.log(data);
                }
            }
        })

        app.component(
            'MyHead',
            {
                //子传父1:定义emits
                emits:['custom-click'],
                template: `
                <header>
                    <h2>logo</h2>
                    <ul>
                        <li>首页</li>
                        <li>视频</li>
                        <li>音乐</li>
                    </ul>
                </header>
                `,
                mounted() {
                    setTimeout(()=>{
                        //子传父2:调用emits，发送数据
                        this.$emit('custom-click' , 'MyHead Data')
                    },2000)
                },
            })

        let vm = app.mount('#app');
    </script>

</body>
</html>